/**
 * @param {string} s
 * @return {character}
 */
var firstUniqChar = function(s) {
    let map = new Map()
    for (let i = 0; i< s.length; i++) {
        let count = map.get(s[i])
        if (map.has(s[i])) {
            map.set(s[i], count +1)
        }else {
            map.set(s[i], 1)
        }
    }
    // return map
    for (let j = 0; j < s.length; j++) {
        if (map.get(s[j]) == 1) {
            return s[j]
        }
    }
    return ' '
};
let s = "abaccdeff"
console.log(firstUniqChar(s))